<?php
namespace app\api\controller\admin;
use app\api\controller\Controller;
use app\api\model\Order as OrderModel;

/**
 * 商户订单管理
 */
class Order extends Controller
{
    /**
     * 商户订单列表
     */
    public function lists($dataType,$shop_id)
    {
        $model = new OrderModel;
        $list = $model->getOnList($dataType,$shop_id);
        return $this->renderSuccess(compact('list'));
    }

    /**
     * 订单详情信息
     */
    public function detail($order_id)
    {
        $order = OrderModel::detail($order_id);
        return $this->renderSuccess(compact('order'));
    }

    /**
     * 上菜完毕
     */
    public function delivery($order_id)
    {
        $model = OrderModel::detail($order_id);
        if ($model->delivery()) {
            return $this->renderSuccess([],'操作成功');
        }
        return $this->renderError($model->getError());
    }
	
	/**
     * 开始配送
     */
    public function receipt_star($order_id)
    {
        $model = OrderModel::detail($order_id);
        if ($model->receipt_star()) {
            return $this->renderSuccess([],'操作成功');
        }
        return $this->renderError($model->getError());
    }
	
	/**
     * 配送完成
     */
    public function receipt_end($order_id)
    {
        $model = OrderModel::detail($order_id);
        if ($model->receipt_end()) {
            return $this->renderSuccess([],'操作成功');
        }
        return $this->renderError($model->getError());
    }
	
	/**
     * 配送
     */
    public function peisong($order_id,$shop_clerk_id)
    {
		$data['shop_clerk_id'] = $shop_clerk_id;
        $model = OrderModel::detail($order_id);
        if ($model->delivery($data)) {
            return $this->renderSuccess([],'配送成功');
        }
        return $this->renderError($model->getError());
    }
}
